import request from '@/request';
import type { editFormData, addFormData } from "../@types/index"

type WithPagination = {
    page: number;
    pageSize: number;
    isAll?: false; // 可选，但默认就是 false
};

type WithoutPagination = {
    isAll: true;
    page?: never;
    pageSize?: never;
};

type Params = {
    username?: string;
} & (WithPagination | WithoutPagination);


/**查询用户列表*/
export const getAdminUser = (params: Params) => request({
    url: '/api/v2/admin/getAdminUser',
    method: 'get',
    params
})

/**获取权限列表*/
export const getPermissionList = () => request({
    url: '/api/v2/admin/getAllRoles',
    method: 'get',
})

/**更新用户信息*/
export const updateUserInfo = (data: editFormData) => request({
    url: '/api/v2/admin/updateAdminUser',
    method: 'post',
    data
})

/**添加用户*/
export const addUserInfo = (data: addFormData) => request({
    url: '/api/v2/admin/addAdminUser',
    method: 'post',
    data
})

/**删除用户*/
export const deleteUserInfo = (data: { ID: string }) => request({
    url: '/api/v2/admin/delAdminUser',
    method: 'post',
    data
})